<?php
session_start();
require_once "../includes/config.php";

$emsg="";

if(isset($_POST['signin']))
{	
	$username=$_POST['username'];
	$password=$_POST['password'];
	$sql_selusr="SELECT * FROM tbl_admin where username='$username' AND password='$password' AND status='a'";
	$rst_selusr=mysql_query($sql_selusr);
	if($rst_selusr) {	
		$num=mysql_num_rows($rst_selusr);
		$row_selusr=mysql_fetch_array($rst_selusr);
		$admin_id=$row_selusr['admin_id'];
		if($num>0)
		{
			$emsg="";			
			$_SESSION['admin_id']=$admin_id;
			$_SESSION['admin_name']=$username;
			header("location:index.php?cat");
		}
			else {
			$emsg="Invalid username and password, Enter valid one";
		}
	}
	else {
		$emsg = mysql_error();
	} 
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> Swapen - Admin Home </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="css/style.css" type="text/css" rel="stylesheet">
<script type="text/javascript" language="javascript" src="js/functions.js"></script>
</head>

<body>
<table width="83%" border="0" align="center" cellspacing="0">
  <tr>
    <td colspan="3"><table width="100%"  border="0" cellspacing="0" cellpadding="0" background="../images/header.jpg">
      <tr>
        <td width="10" height="116"><div align="center"></div></td>
        <td width="100%">
		<div style="padding-top:25px; vertical-align:middle;">
			<img src="../images/logo.png">
		 </div></td>
      </tr>
    </table></td>
  </tr>
  <tr>
  <td colspan="3">
  <table width="100%"  border="1" align="center" cellspacing="0" class="container">
   <tr>
     <td width="99%" height="319">
       <p>&nbsp;</p>
       <p>&nbsp;</p>
       <p>&nbsp;</p>
	  <form name="form1" id="form1" action="" method="post">
		 <input type="hidden" name="keyword" id="keyword"><table width="57%"  border="1" align="center" cellspacing="0" class="container" >
       <tr>
         <td width="351" height="27" class="tdHeader">Sign In</td>
       </tr>
       <tr>
         <td height="90"><table width="100%"  border="0">
             <tr>
               <td>&nbsp;</td>
               <td colspan="4">Sign In here...</td>
               <td height="18">&nbsp;</td>
             </tr>
             <tr>
               <td width="2%">&nbsp;</td>
               <td colspan="4" style="text-align:center" class="redStar">
			   		<?php if($emsg!='') {
					   		echo $emsg;  
					   	  }
					?>
					<div id="rst-signin"></div>
			   </td>
               <td width="2%" height="18">&nbsp;</td>
             </tr>
             <tr>
               <td>&nbsp;</td>
               <td>&nbsp;</td>
               <td>Admin Name</td>
               <td><input type="text"  name="username" id="username"  class="text"></td>
               <td>&nbsp;</td>
               <td height="17">&nbsp;</td>
             </tr>
             <tr>
               <td>&nbsp;</td>
               <td width="12%">&nbsp;</td>
               <td width="26%">Password</td>
               <td width="55%"><input type="password" name="password" id="password" class="text"></td>
               <td width="3%">&nbsp;</td>
               <td height="19">&nbsp;</td>
             </tr>
             <tr>
               <td>&nbsp;</td>
               <td colspan="3">&nbsp;</td>
               <td>&nbsp;</td>
               <td height="20">&nbsp;</td>
             </tr>
             <tr>
               <td>&nbsp;</td>
               <td colspan="3"><div align="center">
                   <input type="submit" name="signin" id="signin" value="Sign In" class="button">
               </div></td>
               <td>&nbsp;</td>
               <td height="20">&nbsp;</td>
             </tr>
             <tr>
               <td>&nbsp;</td>
               <td colspan="3">&nbsp;</td>
               <td>&nbsp;</td>
               <td height="20">&nbsp;</td>
             </tr>
         </table></td>
       </tr>
     </table></form>
       <p>&nbsp;</p>
       <p>&nbsp;</p>
       <p>&nbsp;</p>
       <p>&nbsp;</p></td>
     </tr>
  </table>
</table>
</body>
</html>
